package com.mbyte.easy.security.mapper;

import java.util.List;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.mbyte.easy.security.entity.SysUser;
import com.mbyte.easy.security.entity.SysUserRoles;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

public interface SysUserRolesMapper extends BaseMapper<SysUserRoles> {
    int insert(SysUserRoles record);

    int insertSelective(SysUserRoles record);
    /**
     * 根据user id查询用户管理的权限信息
     * @param sysUserId
     * @return
     */
    List<SysUserRoles> selectByUserId(Long sysUserId);
    
    /**
     * 通过角色id解除用户角色的绑定
     * @param roleId
     * @return
     */
    int deleteUserRolesById(Long roleId);
    
    /**
     * 通过用户id解除角色的绑定
     * @param roleId
     * @return
     */
    int deleteByUserRoleId(Long roleId);

    /**
     * 根据 roles_id 查询 sys_user_id
     * @param rolesId
     * @return
     */
    @Select("select * from sys_user_roles where roles_id = #{rolesId}")
    List<SysUserRoles> selectByRolesId(@Param("rolesId") Long rolesId);

    /**
     * 根据 用户id查找出对应的角色id
     * @param userId
     * @return
     */
    @Select("select * from sys_user_roles where sys_user_id = #{userId}")
    SysUserRoles findRoleIdByUserId(@Param("userId")Long userId);

    List<Long> selectByRoleId(Long roleId);

    
}